class Score 
   
  # Constructor
  def Score() 
    #@m_chord_diagram_array
    #@m_floating_text_array
    @m_guitar_array[0] = Guitar.new 
    @m_guitar_in_array[0] = GuitarIn.new
    #@m_tempo_marker_array
    #@m_dynamic_array
    #@m_alternate_ending_array    
    @m_system_array[0] = System().new
  end
	   
  # Methods
  def valid_guitar_index?(index) 
    return (index < guitar_count())
  end
   
  def guitar_count() 
    return @m_guitar_array.size
  end
   
  def guitar(index) 
    return nil unless valid_guitar_index?(index) 
    return @m_guitar_array[index]
  end
   
  def valid_chord_diagram_index?(index) 
    return (index < chord_diagram_count())
  end
   
  def chord_diagram_count() 
    return @m_chord_diagram_array.size
  end
   
  def chord_diagram(index) 
    return nil unless valid_chord_diagram_index?(index) 
    return @m_chord_diagram_array[index]
  end
   
  def valid_floating_text_index?(index) 
    return (index < floating_text_count())
  end
   
  def floating_text_count() 
    return @m_floating_text_array.size
  end
   
  def floating_text(index) 
    return nil unless valid_floating_text_index?(index) 
    return @m_floating_text_array[index]
  end
   
  def valid_guitar_in_index?(index) 
    return (index < guitar_in_count())
  end
   
  def guitar_in_count() 
    return @m_guitar_in_array.size
  end
   
  def guitar_in(index) 
    return nil unless valid_guitar_in_index?(index) 
    return @m_guitar_in_array[index]
  end

  def valid_tempo_marker_index?(index) 
    return (index < tempo_marker_count())
  end  
   
  def tempo_marker_count() 
    return @m_tempo_marker_array.size
  end
   
  def tempo_marker($index) 
    return nil unless valid_tempo_marker_index?(index) 
    return @m_tempo_marker_array[index]
  end
   
  def valid_dynamic_index?(index) 
    return (index < dynamic_count())
  end
   
  def dynamic_count() 
    return @m_dynamic_array.size
  end
   
  def dynamic(index) 
    return nil unless valid_dynamic_index?(index) 
    return @m_dynamic_array[index]
  end
   
  def valid_alternate_ending_index?(index) 
    return (index < alternate_ending_count())
  end
   
  def alternate_ending_count() 
    return @m_alternate_ending_array.size
  end
   
  def alternate_ending(index) 
    return nil unless valid_alternate_ending_index?(index) 
    return (@m_alternate_ending_array[$index])
  end
   
  def valid_system_index?(index) 
    return (index < system_count())
  end
   
  def system_count() 
    return @m_system_array.size
  end
   
  def system(index) 
    return nil unless valid_system_index?(index) 
    return @m_system_array[index]
  end
     
  # Serialization
  def do_serialize(stream)
    arr = PowerTabArray.new
    arr.do_serialize(stream, @m_guitar_array)
    arr = PowerTabArray.new
    arr.do_serialize(stream, @m_chord_diagram_array)
    arr = PowerTabArray.new
    arr.do_serialize(stream, @m_floating_text_array)
    arr = PowerTabArray.new
    arr.do_serialize(stream, @m_guitar_in_array)
    arr = PowerTabArray.new
    arr.do_serialize(stream, @m_tempo_marker_array)
    arr = PowerTabArray.new
    arr.do_serialize(stream, @m_dynamic_array)
    arr = PowerTabArray.new
    arr.do_serialize(stream, @m_alternate_ending_array)
    arr = PowerTabArray.new
    arr.do_serialize(stream, @m_system_array)    
    unset ($arr)
    return true
  end
      
  def do_deserialize(stream)
    arr = PowerTabArray.new
    @m_guitar_array = arr.do_deserialize(stream, Guitar.new)
    arr = PowerTabArray.new
    @m_chord_diagram_array = arr.do_deserialize(stream, ChordDiagram.new)
    arr = PowerTabArray.new
    @m_floating_text_array = arr.do_deserialize(stream, FloatingText.new)
    arr = PowerTabArray.new
    @m_guitar_in_array = arr.do_deserialize(stream, GuitarIn.new)
    arr = PowerTabArray.new
    @m_tempo_marker_array = arr.do_deserialize(stream, TempoMarker.new)
    arr = PowerTabArray.new
    @m_dynamic_array = arr.do_deserialize(stream, Dynamic.new)
    arr = PowerTabArray.new
    @m_alternate_ending_array = arr.do_deserialize(stream, AlternateEnding.new)
    arr = PowerTabArray.new
    @m_system_array = arr.do_deserialize(stream, System.new)
  end  
   
end
